package com.ideal.manage.esms.repository.project;

import com.ideal.manage.esms.bean.project.EquipmentManage;
import com.ideal.manage.esms.bean.project.EquipmentTemperatureConf;
import com.ideal.manage.esms.bean.project.ParameterInfo;
import com.ideal.manage.esms.repository.framework.BaseRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created By Dai On 2018/4/27
 * Remark: 工程配置 - 对象管理 - 模组温度配置 Repository
 */
public interface EquipmentTemperatureConfRepository extends BaseRepository<EquipmentTemperatureConf, String> {

    /**
     * 根据设备查找到所有的模组温度配置
     * @param id
     * @return
     */
    @Query("select e from EquipmentTemperatureConf e where e.equipment.id=?1 and e.isValid=1 order by e.parameterInfo.id")
    EquipmentTemperatureConf findByEquipmentId(String id);

    /**
     * 根据设备列表找到所有的模组温度配置
     * @param equipmentManageList
     * @return
     */
    @Query("select e from  EquipmentTemperatureConf e where e.equipment in ?1 and e.isValid=1 order by e.parameterInfo.id")
    List<EquipmentTemperatureConf> findByEquipmentList(List<EquipmentManage> equipmentManageList);

    /**
     * 根据设备和温度配置找到对应的中间项
     * @param equipmentManage
     * @param parameterInfo
     * @return
     */
    @Query("select e from EquipmentTemperatureConf e where e.equipment=?1 and e.parameterInfo=?2 and e.isValid=1")
    EquipmentTemperatureConf findByEquipMentAndParameterInfo(EquipmentManage equipmentManage, ParameterInfo parameterInfo);
}
